//*************************************************************************************
//* 作    者： zouhunter
//* 创建时间： 2021-10-07 04:50:38
//* 描    述： 

//* ************************************************************************************
using System;
using System.Collections.Generic;

using UnityEngine;
using UnityEngine.UI;

[UFrame.BridgeUI.Attributes.PanelParent]
public class LocalViewBase : UFrame.BridgeUI.ViewBase, UFrame.IMediator<int>
{
    public virtual IList<int> Acceptors => null;

    public virtual void HandleNotification(int observeKey)
    {

    }

    protected override void OnBinding(GameObject target)
    {
        base.OnBinding(target);
        var selectables = target?.GetComponentsInChildren<Selectable>();
        for (int i = 0; i < selectables?.Length; i++)
        {
            var selectableItem = selectables[i];
            var audioBehaviour = selectableItem.GetComponent<SelectableAudioBehaviour>();
            if(!audioBehaviour)
            {
                audioBehaviour = selectableItem.gameObject.AddComponent<SelectableAudioBehaviour>();
                audioBehaviour.hoverAudioId = GameConfig.Instance.audioId.default_ui_hover;
                audioBehaviour.clickAudioId = GameConfig.Instance.audioId.default_ui_click;
            }
        }
    }
    protected override void OnInitialize()
    {
        base.OnInitialize();
        AppFacade.RegisterMediator(this);
    }

    protected override void OnRelease()
    {
        base.OnRelease();
        AppFacade.RemoveMediator(this);
    }
}

public partial class GameConfig
{
    public partial class AudioId
    {
        public int default_ui_hover;
        public int default_ui_click;
    }
}